<?
include('../controller/handler.php');

$searched = $_POST['img'];

if($searched!=NULL) {
	$hd = new Handler();
	$quantity = $hd->getAutocompleterResults();
	$files = $hd->getUploadedFiles();

	if(count($files)>0) {
		$i = 0;
		$found = 0;
		echo "<ul>";
		while($found<=$quantity && $i<count($files)) {
			if($hd->isImage($files[$i]) && preg_match("/$searched/i", basename($files[$i]))!=0) {
				echo "<li id=\"".$hd->getBaseURL()."uploads/".basename($files[$i])."\"><p class=\"small img_searched\">".basename($files[$i])."</p></li>";
				$found++;
			}	
			$i++;
		}
		echo "</ul>";
	}
}
?>